package com.dkd.manage.task.allocator.model;

import lombok.Data;

import java.util.*;

@Data
public class EmployeeAllocationHistory {
    private Long empId;
    private Map<String, Integer> taskTypeCount = new HashMap<>();
    private Map<String, Double> taskTypeSuccessRate = new HashMap<>();
    private List<Date> recentAssignments = new ArrayList<>();
    private double averageResponseTime = 2.0;
    private int totalAssignments = 0;

    public void recordAssignment(String taskType, boolean success, double responseTime) {
        taskTypeCount.merge(taskType, 1, Integer::sum);
        recentAssignments.add(new Date());

        // 限制历史记录大小
        if (recentAssignments.size() > 100) {
            recentAssignments.remove(0);
        }

        totalAssignments++;
        averageResponseTime = (averageResponseTime * (totalAssignments - 1) + responseTime) / totalAssignments;
    }
}